import math
      
def calc_distance( a, b):
    return math.sqrt( (b[0]-a[0])**2 + (b[1]-a[1])**2 )        

def calc_angle( a, b):
    return norm_angle((math.atan2(b[1]-a[1],b[0]-a[0])*180)/math.pi)
    
def calc_distance_from_O( a):
    return calc_distance((0,0),a)        

def calc_angle_from_O( a):
    
    return calc_angle((0,0),a)    

def norm_angle(a):
    return (a+360)%360 

def angle_is_fwd(a, is_r2l):
    b = norm_angle(a)
    if(b<=90 or b>270):
            return is_r2l
    else:
            return not is_r2l
    
    #return norm_angle(a)-180 > 0 and is_r2l or True  
